home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / ecstr2.arc / STREND.C < prev    next >
C/C++ Source or Header  |  1987-03-04  |  740b  |  35 lines

  1. /*  File   : strend.c
  2.     Author : Richard A. O'Keefe.
  3.     Updated: 23 April 1984
  4.     Defines: strend()
  5.  
  6.     strend(s) returns a character pointer to the NUL which ends s.  That
  7.     is,  strend(s)-s  ==  strlen(s). This is useful for adding things at
  8.     the end of strings.  It is redundant, because  strchr(s,'\0')  could
  9.     be used instead, but this is clearer and faster.
  10.     Beware: the asm version works only if strlen(s) < 65535.
  11. */
  12.  
  13. #include "strings.h"
  14.  
  15. #if    VaxAsm
  16.  
  17. char *strend(s)
  18.     char *s;
  19.     {
  20.        asm("locc $0,$65535,*4(ap)");
  21.        asm("movl r1,r0");
  22.     }
  23.  
  24. #else  ~VaxAsm
  25.  
  26. char *strend(s)
  27.     register char *s;
  28.     {
  29.        while (*s++);
  30.        return s-1;
  31.     }
  32.  
  33. #endif VaxAsm
  34.  
  35.